package com.jing.cloud.service.buddy.dao.impl;

import com.google.common.collect.Maps;
import com.jing.cloud.service.buddy.bean.Buddy;
import com.jing.cloud.service.buddy.dao.BuddyDao;
import com.jing.cloud.service.dao.impl.DbDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;


@Repository
public class BuddyDaoImpl extends DbDaoImpl<Buddy> implements BuddyDao {
    @Override
    public Buddy findByUserAndTarget(long userId, long buddyId) {
        Map<String, Object> condition = Maps.newHashMap();
        condition.put("userId", userId);
        condition.put("buddyId", buddyId);
        List<Buddy> buddies = query(condition);
        if (null != buddies && !buddies.isEmpty()) {
            return buddies.get(0);
        }
        return null;
    }
}
